﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wsitech.BLL;
using Wsitech.Model;

public partial class News_video : System.Web.UI.Page
{
    protected readonly string parentSitemapid = HttpContext.Current.Request["sitemapid"] ?? "";

    /// <summary>
    /// 子栏目列表
    /// </summary>
    public IList<SiteMapInfo> siteMapList
    {
        get
        {
            IList<SiteMapInfo> list = new List<SiteMapInfo>();
            if (Request["sitemapid"] != null)
            {
                list = SiteMapInfoBLL.Instance.GetSiteMapByParentId(parentSitemapid);
            }
            return list;
        }
    }


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["pagesize"] != null)
            {
                ddlPageSize.SelectedValue = Request["pagesize"];
            }
            bindVideoInfo();
        }
    }

    //绑定视频信息列表
    private void bindVideoInfo()
    {
        string sitemapid = Request["subid"] ?? "";
        if (sitemapid == "")
        {
            IList<SiteMapInfo> list = SiteMapInfoBLL.Instance.GetSiteMapByParentId(parentSitemapid);
            if (list != null && list.Count > 0)
            {
                sitemapid = list[0].SitemapId;
            }
        }
        int count = 0;
        AspNetPager1.PageSize = int.Parse(ddlPageSize.SelectedValue);
        repMain.DataSource = TextInfoBLL.Instance.GetActivePagedListBySiteMapID(sitemapid, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, ref count);
        repMain.DataBind();

        AspNetPager1.RecordCount = count;
    }

    //分页
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindVideoInfo();
    }

    //切换每页显示个数
    protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
        string redirectUrl = string.Format("{0}?sitemapid={1}&pagesize={2}", Request.Path, parentSitemapid, ddlPageSize.SelectedValue);
        if (Request["subid"] != null)
        {
            redirectUrl += "&subid=" + Request["subid"];
        }

        Response.Redirect(redirectUrl);
    }
}